package com.glela.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import org.apache.commons.collections4.MapUtils;
import com.glela.order.model.OrderObject;
import com.glela.order.service.OrderService;

public class ValidationOrder implements Serializable,Callable<List<Map<String, Object>>>{
	private static final long serialVersionUID = -1637272933768082049L;
    private List<OrderObject> listOBJ;
    private OrderService orderService2;
	 
	public ValidationOrder(List<OrderObject> listOBJ, OrderService orderService2) {
		super();
		this.listOBJ = listOBJ;
		this.orderService2 = orderService2;
	}

	public List<Map<String, Object>> call(){
		List<Map<String, Object>> result=new ArrayList<Map<String, Object>>();
			Map<String, Object> temp=null;
			//验证已支付
			for(OrderObject orderObj:listOBJ){
				try {
					 temp=orderService2.validationOrderObj(orderObj);
				} catch (Exception e) {
					temp=new HashMap<String, Object>();
					temp.put("1",orderObj.getOrderSn());
					temp.put("2","订单验证异常 请重新验证"+e.getMessage());
				}
				if(MapUtils.isNotEmpty(temp)){
					result.add(temp);
				}
			}
		return result;
	}
}
